package core.demo;

import core.obj.Sort;
import javafx.util.Pair;

public class ChooseSort<T> extends Sort<T> {
    public ChooseSort(Comparable<T>[] arr) {
        super(arr);
    }

    @Override
    public void sort() {
        for(int i = 0;i < arr.length - 1;i++)
        {
            int min = i;
            for(int j = i+1;j < arr.length;j++)
            {
                pointers.addElement(new Pair<>(i,j));//
                if(arr[j].compareTo((T) arr[i]) < 0)
                {
                    process.addElement(new Pair<>(i,j));//
                    min = j;
                }
            }

            Comparable<T> temp = arr[i];
            arr[i] = arr[min];
            arr[min] = temp;
        }
    }
}
